package com.moweilin.mo_utils.collection;

import org.apache.commons.lang3.ArrayUtils;

import java.util.Iterator;
import java.util.Map;

/**
 * Created by moweilin on 2017/2/18.
 */
public class MoArrayUtils {
    public static Object[][] merge(Object[][] source,Object[][] target){
        Map<Object,Object> map = ArrayUtils.toMap(source);
        map.putAll(ArrayUtils.toMap(target));
        Object[][] result = new Object[map.size()][2];
        Iterator<Map.Entry<Object,Object>> iterator = map.entrySet().iterator();
        int ii = 0;
        while (iterator.hasNext()){
            Map.Entry<Object,Object> entry = iterator.next();
            result[ii][0]=entry.getKey();
            result[ii][1]=entry.getValue();
            ii ++;
        }
        return result;
    }
}
